package com.schoolcloud.serve.controller;

import com.schoolcloud.common.model.R;
import com.schoolcloud.serve.entity.SpuCategory;
import com.schoolcloud.serve.service.SpuCategoryService;
import com.schoolcloud.serve.vo.SpuCategoryVO;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/serve/re-market/spu-category")
@RequiredArgsConstructor
public class SpuCategoryController {
    private final SpuCategoryService spuCategoryService;
    @GetMapping("tree-list")
    public R<List<SpuCategoryVO>> getTreeList() {
        return R.ok(spuCategoryService.getTreeList());
    }

    @PostMapping
    public R save(@RequestBody SpuCategory spuCategory) {
        spuCategoryService.save(spuCategory);
        return R.ok();
    }
    @PutMapping
    public R update(@RequestBody SpuCategory spuCategory) {
        spuCategoryService.updateById(spuCategory);
        return R.ok();
    }
}
